# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Rémy Oudompheng <remy@archlinux.org>
# Contributor: Firmicus <francois.archlinux.org>
# Contributor: bender02 at gmx dot com

pkgname=asymptote
pkgver=2.86
pkgrel=3
pkgdesc='A vector graphics language (like metapost)'
arch=(loong64 x86_64)
url='http://asymptote.sourceforge.net/'
license=(GPL3)
depends=(texlive-basic gc freeglut gsl fftw libsigsegv boost-libs)
makedepends=(cmake ghostscript imagemagick texlive-latexextra texlive-plaingeneric texlive-binextra python-pyqt5 glu glm boost doxygen)
optdepends=('python-pyqt5: for the xasy GUI'
            'python-cson: for the xasy GUI'
            'ghostscript: PDF output')
source=(https://github.com/vectorgraphics/asymptote/archive/$pkgver/$pkgname-$pkgver.tar.gz)
sha256sums=('3ebcc90beb67bf7f8575fb519cb9d5d3c6cfd77f97ee1f69d53af458563c8aaa')

prepare() {
  cd $pkgname-$pkgver
  ./autogen.sh
}

build() {
  cd $pkgname-$pkgver
  CXXFLAGS+=" -I$srcdir/$pkgname-$pkgver" \
  ./configure --enable-gc=/usr \
              --prefix=/usr \
              --with-latex=/usr/share/texmf/tex/latex \
              --with-context=/usr/share/texmf/tex/context \
              --enable-offscreen
  make all
}

check() {
  cd $pkgname-$pkgver
  make check-all
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install-all
  # this dir contains png files that are already embedded in the pdf documentation:
  rm -rf "$pkgdir"/usr/share/info/asymptote

  # copy some data files to their correct location
  mkdir -p "$pkgdir"/usr/share/emacs/site-lisp
  cp "$pkgdir"/usr/share/asymptote/*.el "$pkgdir"/usr/share/emacs/site-lisp
  mkdir -p "$pkgdir"/usr/share/vim/vimfiles/syntax
  cp "$pkgdir"/usr/share/asymptote/*.vim "$pkgdir"/usr/share/vim/vimfiles/syntax
  mkdir -p "$pkgdir"/usr/share/org.kde.syntax-highlighting/syntax
  cd "$pkgdir"/usr/share/asymptote/
  sh asy-kate.sh
  mv asymptote.xml "$pkgdir"/usr/share/org.kde.syntax-highlighting/syntax
}
